<?php
/***
 * 描述：用户管理[管理员权限]
 * @category		Admin		
 * @package			Action			
 * @subpackage			
 * @author			wanght <whtaok@gmail.com>
 * @since			2013-4-6
 * @version			$Id: UserManageAction.class.php 3 2013-10-14 02:49:41Z whtaok@gmail.com $
 */
class UserManageAction extends AdminAction {
	/**
	 * 用户管理首页面
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function indexAct() {
		$search = array(
				'shop_id'=>I('shop_id'),
				'role_name'=>I('role_name'),
				'name'=>I('name'),
				'mobile'=>I('mobile'),
			);
		$mod=new ShopUserModel();
		$mod->setModWhere($search);
		$list = $mod->select();
		$this->assign('list',$list);
		$this->assign('search',$search);
		$this->assign('shopList',shop_list());
		$this->assign('roleList',role_list());
		$this->display('index');
	}
	
	/**
	 * 显示添加页面
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function showAddAct() {
		$this->assign('shopList',shop_list());
		$this->assign('roleList',role_list());
		$this->display('add');
	}
	
	/**
	 * 添加操作
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function doAddAct() {
		$mod=new ShopUserModel();
		
		if(!$mod->create()){
			$this->error($mod->getError());
		}
		$mod->password = md5(I('password_char'));
		$mod->add();
		$this->success('添加成功', U('index'));
	}
	
	/**
	 * 显示编辑页面
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function showUpdAct($id) {
		$mod=new ShopUserModel();
		$detail = $mod->find($id);
		$this->assign("detail",$detail);
		$this->assign('search',array('shop_id'=>$detail['shop_id'],'role_name'=>$detail['role_name']));
		$this->assign('shopList',shop_list());
		$this->assign('roleList',role_list());
		$this->display('upd');
	}
	
	/**
	 * 编辑操作
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function doUpdAct($id) {
		$mod=new ShopUserModel();
		if(!$mod->create()){
			$this->error($mod->getError());
		}
		$mod->password = md5(I('password_char'));
		$mod->save();
		$this->success('保存成功', U('index'));
	}
	
	/**
	 * 删除操作
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function doDelAct($id) {
		$mod = new ShopUserModel();
		$mod->idForWhere($id);
		$mod->setField('is_valid','4');
		$this->success('删除成功', U('index'));
	}	

}

?>